package springMVC.returnParams;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.HashMap;

/**
 * @Author quan
 * @Description 返回json对象
 * @Date 2023/7/22 11:07
 */

@Controller
@RequestMapping("/web")
public class Demo3_ReturnJson {
    @RequestMapping("/return3")
    @ResponseBody
    //返回map，Spring自动将类型转化为json格式。对象也是一样，自动转为Json格式。
    public HashMap<String, String> return3() {
        HashMap<String, String> map = new HashMap<>();
        map.put("Java", "Java Value");
        map.put("MySQL", "MySQL Value");
        map.put("Redis", "Redis Value");
        return map;
    }
}
